package com.specialized.coupon.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.specialized.common.core.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//import com.specialized.common.log.annotation.Log;
//import com.specialized.common.log.enums.BusinessType;
import com.specialized.common.security.annotation.RequiresPermissions;
import com.specialized.coupon.domain.Invite;
import com.specialized.coupon.service.IInviteService;
import com.specialized.common.core.web.controller.BaseController;
import com.specialized.common.core.utils.poi.ExcelUtil;

/**
 * 邀请记录Controller
 *
 * @author djh
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/Invite")
public class InviteController extends BaseController {
    @Autowired
    private IInviteService inviteService;

/**
 * 查询邀请记录列表
 */
@RequiresPermissions("coupon:Invite:list")
@GetMapping("/list")
    public Result list(Invite invite) {
        startPage();
        List<Invite> list = inviteService.selectInviteList(invite);
        return getDataTable(list);
    }

    /**
     * 导出邀请记录列表
     */
//    @Log(title = "邀请记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Invite invite) {
        List<Invite> list = inviteService.selectInviteList(invite);
        ExcelUtil<Invite> util = new ExcelUtil<Invite>(Invite. class);
        util.exportExcel(response, list, "邀请记录数据");
    }

    /**
     * 获取邀请记录详细信息
     */
    @GetMapping(value = "/{inviteId}")
    public Result getInfo(@PathVariable("inviteId") Long inviteId) {
        return success(inviteService.selectInviteByInviteId(inviteId));
    }

    /**
     * 新增邀请记录
     */
//    @Log(title = "邀请记录", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody Invite invite) {
        return toAjax(inviteService.insertInvite(invite));
    }

    /**
     * 修改邀请记录
     */
//    @Log(title = "邀请记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody Invite invite) {
        return toAjax(inviteService.updateInvite(invite));
    }

    /**
     * 删除邀请记录
     */
//    @Log(title = "邀请记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{inviteIds}")
    public Result remove(@PathVariable Long[] inviteIds) {
        return toAjax(inviteService.deleteInviteByInviteIds(inviteIds));
    }





}
